const { goodsParams } = require('../constant/error_type')
//参数校验
const validator = async (ctx, next) => {
    try {
        //商品校验
        ctx.verifyParams({
            goods_name: { type: 'string', required: true },
            goods_price: { type: 'number', required: true },
            goods_num: { type: 'number', required: true },
            goods_img: { type: 'string', required: true }
        })

    } catch (error) {
        // console.log(error);
        goodsParams.result
        return ctx.app.emit('error', goodsParams, ctx)
    }
    await next()
}

module.exports = { validator }